#include "stdafx.h"
#include "CppUnitTest.h"
#include <iostream>
#include <cstring>

using namespace std;
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace NativeTest_Question2
{		
	void Swap(char& a, char&  b)
	{
		a = a^b;
		b=  a^b;
		a = a^b;
	}

	void Reverse(char* str)
	{
		char* end = str;
		if (str)
		{
			while(*end)
			{
				++end;
			}
			end--;

			char t;

			while(str < end)
			{
				t = *str;
				*str = *end;
				*end = t;
				Swap(*str, *end);
				str++;
				end--;
			}
		}
	}

}
namespace NativeTest
{
	using namespace NativeTest_Question2;

	TEST_CLASS(Question2)
	{
	public:

		TEST_METHOD(Question2_TestMethod1)
		{
			char str[] = "abcdefg";
			Reverse(str);
			Assert::AreEqual(str, "gfedcba");
		}

		// check empty
		TEST_METHOD(Question2_TestMethod2)
		{
			char str[] = "";
			Reverse(str);
			Assert::AreEqual(str, "");
		}

		// check same one
		TEST_METHOD(Question2_TestMethod3)
		{
			char str[] = "aaaaa";
			Reverse(str);
			Assert::AreEqual(str, "aaaaa");
		}

	};
}